<!-- src/views/MyPage.vue -->
<template>
  <div class="my-page">
    <h3>这是我的自定义页面</h3>
    <p>支持表单、表格、按钮等复杂结构。</p>
    <el-input
      v-model="msg"
      placeholder="请输入内容"
      style="width: 200px; margin: 10px 0;"
    />
    <el-button type="primary" @click="submit">提交</el-button>
  </div>
</template>

<script>
export default {
  name: 'MyPage',
  data() {
    return {
      msg: '' // 初始为空
    };
  },
  mounted() {
    console.log('✅ MyPage 已挂载');
  },
  methods: {
    // ✅ 必须提供 getData 方法
    getData() {
      console.log('📄 MyPage.getData() 被调用，当前 msg =', this.msg);
      return {
        msg: this.msg,
        timestamp: Date.now()
      };
    },
    submit() {
      const data = this.getData();
      this.$emit('submit', data);
      console.log('📤 emit submit:', data);
    }
  }
};
</script>

<style scoped>
.my-page {
  padding: 20px;
  background: #f9f9f9;
  border-radius: 8px;
}
</style>
